package cn.dkk.behavior_design.interpret;

/**
 * @author dkk
 * @date 2022/8/1
 * @desc
 */
public class Plus extends AbstractExpression{

    /**
     * 加号左边的表达式
     */
    private AbstractExpression left;
    /**
     * 加号右边的表达式
     */
    private AbstractExpression right;

    @Override
    int interpret(Context context) {
        return left.interpret(context)+right.interpret(context);
    }

    @Override
    public String toString() {
        return ("("+right.toString()+"+"+left.toString()+")");
    }

    public Plus(AbstractExpression left, AbstractExpression right) {
        this.left = left;
        this.right = right;
    }
}
